package com.auth.config.security;

import com.redis.serialize.EntityRedisSerializer;
import org.springframework.security.oauth2.provider.token.store.redis.StandardStringSerializationStrategy;

/**
 * @author hewei
 * @date 2022/5/31 17:41
 * @Description
 */
public class CustomSerializationStrategy extends StandardStringSerializationStrategy {

    private static final EntityRedisSerializer OBJECT_SERIALIZER = new EntityRedisSerializer();

    @Override
    protected <T> T deserializeInternal(byte[] bytes, Class<T> clazz) {
        return (T) OBJECT_SERIALIZER.deserialize(bytes);
    }

    @Override
    protected byte[] serializeInternal(Object object) {
        return OBJECT_SERIALIZER.serialize(object);
    }
}
